//
//  CTProgressCell.m
//  digitalCurrency
//
//  Created by 默认账户 on 2019/6/2.
//  Copyright © 2019 XinHuoKeJi. All rights reserved.
//

#import "CTProgressCell.h"

@implementation CTProgressCell

+ (instancetype)createTableView:(UITableView *)tableView {
    CTProgressCell *cell = [tableView dequeueReusableCellWithIdentifier:@"qgcell"];
    cell.selectionStyle  = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor blackColor];
    [cell makeViews];
    
    return cell;
}
    
- (void)makeViews {

    UIView *bgview = [[UIView alloc]initWithFrame:CGRectMake(12, 0, SCREEN_WIDTH-24, 100)];
    [self.contentView addSubview:bgview];
    bgview.backgroundColor = [UIColor colorWithHEX:mainBlackColor];
    bgview.layer.cornerRadius = 3;
    
    [bgview addSubview:self.progressBgView];
    self.progressBgView.frame = CGRectMake(20, 33, SCREEN_WIDTH-64, 16);
    
    [bgview addSubview:self.progressView];
    self.progressView.frame = CGRectMake(20, 33, 1, 16);
    
    [bgview addSubview:self.canUsedCount];
    [self.canUsedCount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.top.mas_equalTo(15);
        make.height.mas_equalTo(14);
    }];
    
    [bgview addSubview:self.usedCount];
    [self.usedCount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.bottom.mas_equalTo(-12);
        make.height.mas_equalTo(14);
    }];
    
    [bgview addSubview:self.percentLabel];
    [self.percentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.bottom.mas_equalTo(-24);
        make.height.mas_equalTo(16);
    }];
    
}
    
- (UILabel *)canUsedCount {
    if (!_canUsedCount) {
        _canUsedCount = [[UILabel alloc] init];
        _canUsedCount.textColor = [UIColor whiteColor];
        _canUsedCount.font = [UIFont systemFontOfSize:14];
        _canUsedCount.textAlignment = NSTextAlignmentCenter;
        NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:LocalizationKey(@"当前限量 0 MOS") attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: 14],NSForegroundColorAttributeName: [UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1.0]}];
        _canUsedCount.attributedText = string;
        _canUsedCount.hidden = YES;
    }
    return _canUsedCount;
}

- (UILabel *)percentLabel {
    if (!_percentLabel) {
        _percentLabel = [[UILabel alloc] init];
        _percentLabel.textColor = [UIColor whiteColor];
        _percentLabel.font = [UIFont systemFontOfSize:14];
        _percentLabel.textAlignment = NSTextAlignmentCenter;
        NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@",LocalizationKey(@"Current buying progress"),@"0.00%"] attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: 14],NSForegroundColorAttributeName: [UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1.0]}];
        _percentLabel.attributedText = string;
    }
    return _percentLabel;
}

    
- (UILabel *)usedCount {
    if (!_usedCount) {
        _usedCount = [[UILabel alloc] init];
        _usedCount.textColor = [UIColor whiteColor];
        _usedCount.font = [UIFont systemFontOfSize:14];
        NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:LocalizationKey(@"已抢 0 MOS") attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: 14],NSForegroundColorAttributeName: [UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1.0]}];
        _usedCount.attributedText = string;
        _usedCount.hidden = YES;
    }
    return _usedCount;
}
    
- (UIView *)progressBgView {
    if (!_progressBgView) {
        _progressBgView = [[UIView alloc] init];
        _progressBgView.backgroundColor = [UIColor colorWithHEX:@"c5c5c5"];
        _progressBgView.layer.cornerRadius = 8;
    }
    
    return _progressBgView;
}

- (UIView *)progressView {
    if (!_progressView) {
        _progressView = [[UIView alloc] init];
        _progressView.backgroundColor = [UIColor colorWithHEX:maincolor];
        _progressView.layer.cornerRadius = 8;
    }
    
    return _progressView;
}
    
@end
